package com.boboPlanet.fallback;

import com.boboPlanet.comm.enums.FeignErrorEnum;
import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.feign.UserAuthApi;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/5/10
 * @Company planet
 **/
@Slf4j
@Component
@Deprecated
public class UserAuthFallbackImpl implements FallbackFactory<UserAuthApi> {
    @Override
    public UserAuthApi create(Throwable cause) {
        return new UserAuthApiImpl(cause);
    }

    public static class UserAuthApiImpl implements UserAuthApi{

        private final Throwable throwable;
        public UserAuthApiImpl(Throwable cause){
            this.throwable = cause;
        }

        @Override
        public Boolean getJwtClaimBySign(String sign) {
            log.error("getJwtClaimBySign fail,param is: {},errorReason is: {}",sign,throwable);
//            return ResponseResult.error(FeignErrorEnum.FEIGN_USER_AUTH_ERROR,null);
            return false;
        }

        @Override
        public Boolean judgeUserIsExpire(String sign) {
            log.error("judgeUserIsExpire fail,param is: {},errorReason is: {}",sign,throwable);
//            return ResponseResult.error(FeignErrorEnum.FEIGN_USER_AUTH_ERROR,null);
            return false;
        }
    }
}
